package HomeWork5;

import java.sql.*;

public class DruidTest {
    public static void main(String[] args) {
        Connection connection=null;
        PreparedStatement preparedStatement =null;
        ResultSet resultSet=null;
        try {
            connection = DruidUtils.getConnect();
            System.out.println(connection);
            String sql="select * from employee where name=? and gender=?";
            preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"小李");
            preparedStatement.setString(2,"男");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()){
                int id = resultSet.getInt("id");
                String name = resultSet.getString("NAME");
                String gender = resultSet.getString("gender");
                double salary = resultSet.getDouble("salary");
                double bonus = resultSet.getDouble("bonus");
                Date join_date = resultSet.getDate("join_date");
                System.out.println(id+"--"+name+"--"+gender+"--"+salary+"--"+bonus+"--"+join_date);
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            DruidUtils.close(connection,preparedStatement,resultSet);
        }

    }
}
